home *** CD-ROM | disk | FTP | other *** search
/ LOGIC Apps / Logic-APPLE_II_APPS.iso / mac / LOGIC Apple II 5.25" Library - ProDOS / PRO009.dsk / EXEC.FILE.INFO.txt < prev    next >
Text File  |  2012-02-16  |  16KB  |  85 lines

  1.                       TEXT AND EXEC FILES
  2.  
  3.    Officially, there's no such thing as an EXEC file. In informal but widespread usage, the term refers to a TEXT file upon which the EXEC command can be productively used.
  4.  
  5.    A TEXT file is one of several different types of files that can be stored on your disk. If you CATalog a ProDOS disk with several files stored on it, you will see on your screen that the column just to the right of your ProDOS filenames consists of literal abbreviations such as BAS, BIN, and TXT (and others are possible; these are the most common.) TXT means the file is a TEXT file. DOS uses single-letter abbreviations (T,B,A) in the far-left column, standing for TEXT, BINARY, and APPLESOFT BASIC respectively.
  6.  
  7.    A TEXT file is a file whose contents are interpreted as characters encoded using the ASCII format,i.e., letters and symbols represented by numbers. A BIN file, by contrast, is a file whose data are to be interpreted in binary form. A BAS file is one which includes specially encoded Applesoft BASIC programs.
  8.  
  9.    Many word processing programs save their files to disk as TEXT files (several popular ones do not, however.) Applewriter IIe does, and in Appleworks' Word Processing mode a file MAY at user's option be saved as a TEXT file. ANY FILE YOU DOWNLOAD FROM COMPUSERVE WILL BE SAVED TO YOUR DISK, IN THE FIRST INSTANCE, AS A TEXT FILE AND (ASSUMING IT IS A PROGRAM RATHER THAN A DOCUMENT) YOU MAY USE THE DOS OR PRODOS "EXEC" COMMAND TO TURN IT INTO AN OPERATING PROGRAM.
  10.  
  11.  
  12.                      A GOODIE
  13.  
  14.   This goodie is for programmers, although you don't have to be a hotshot to take advantage of it. Writing your own programs, or modifying the ones you download or obtain elsewhere, is fun but it does involve a lot of tricky and tedious work at times. One of the more annoying and time consuming aspects is retyping a particular "routine", a section of a program that performs a particular task such as a menu, a BASIC PRINT USING subroutine, or such. You can eliminate or minimize this task by creating a program subroutine library on disk. The library will consist of TEXT files containing Applesoft lines. If you have the TEXTfiles consisting of such routines saved to disk, you can EXEC them into your computer's memory and avoid retyping them. You'll also avoid aggravating typing errors by using this technique.
  15.  
  16.    Let me take this backwards. Let's assume you've got a library disk like mine. I work in ProDOS because I like its orderly scheme of disk organization, so my examples will be given using ProDOS conventions, but the same technique works in DOS. My disk is named /LIBRARY.  I have subdirectories on it named /USING, containing three or four PRINT USING simulations, subroutines written in Applesoft and saved as TEXT files; /MENUS, containing a half dozen or so different menu subroutines; /SORTS, containing several sort routines, and so
  17. rth. Let's say I'm working on a program that needs a cursorbar menu, the type where you move a cursor up or down using the arrow keys then select item 1,2,3, etc. by pressing RETURN when the proper selection is highlighted. I learned how to write one of those a while back, and I could write one again from scratch with a little head scratching.  Or, I could keep my subroutines printed on sheets of paper and retype them when needed. Or, I could thumb through Nibble back issues until I found the article 3 years ago where they showed me how to do it, THEN retype it. Instead, while the program I'm working on is in memory, I can simply insert my /LIBRARY disk in the drive and type EXEC/LIBRARY/MENUS/CURSORBAR.MENU, then press RETURN. My disk operating system will type the subroutine into memory and I've just saved from 10 to 30 minutes.
  18.  
  19.    You do have to be aware of a few things. Naturally with BASIC you have to be line-number conscious. If the program in memory consists of lines numbered 10 through 300 in increments of 5, and the EXEC file CURSORBAR routine was numbered 55 through 70, then when you EXEC it into memory you will overwrite the old lines 55 through 70. You can solve this problem in at least a couple of different ways. One: before you EXEC, edit the TEXT file with a word processor and renumber the lines to fit the program you'll be EXEC'ing the subroutine into. Another: make sure all your Applesoft lines included in the EXEC files to be used for this purpose have very high line numbers (like 60000 and up.) Most of your programming in progress won't employ line numbers that high; it certainly need not, and since you're aware you may be using this EXEC technique you can be sure to avoid that high end of the Applesoft line number scheme. Then when you EXEC the CURSORBAR.MENU subroutine into memory, it won't overwrite any lines in memory and after EXECing you can renumber it to fit the rest of the program in memory using GPLE or DOUBLE TAKE or simply the built in line editor. Of course, if it's a menu you'll also have to rename the selection categories and a few other details, but you won't have to type in all that IF X<>Q AND Y>=128-K stuff. That leads to another tip: when appropriate, try to make any variable names in your EXECable subroutines consist of bizarre or unlikely combinations so the variable names in your program-in-general won't be affected or interfere with the operation of your subroutine.  Of course, some of your EXECable subroutines will have to incorporate the variable names used in your program-in-general to be useful; you be the judge which situation is more likely to arise on a particular subroutine.
  20.  
  21.                        MAKING AN EXEC FILE
  22.  
  23.  
  24.     One way is to use your word processor. The first time you come up with a subroutine that makes a good candidate for your permanent /LIBRARY disk, type it into your word processor. Then SAVE it as a TEXT file . If your word processor doesn't save TEXT files of course, this technique doesn't work. As you do this, something may dawn on you: a word processor is a fairly good tool for typing programs, not just subroutines. You can easily edit the file in memory; many WP programs have global search/replace features which allow changing a word or phrase throughout the program by using just one set of keystrokes; many WPs including Appleworks will print your listing with automatic page breaks; and a number of other features are available that recommend most WPs for this task. Of course, you'll have to EXEC your files before you can run them, but you won't have to pay for a line editor program either, and you won't (heaven forfend!) have to grapple with the Apple's own built-in line editor, which is OK for correcting the occasional error but not ideal for heavy-duty editing. And you'll start making your expensive word processor do a little double duty it didn't expect to have to do. This really is a good way to type in lengthy program listings from magazines, as well as to create an EXECfile library.
  25.  
  26.       (I should say that I prefer using Beagle Brothers' Global Program Line Editor for such tasks since you can RUN your program immediately after making the changes to see how they work, but if you don't have it or a similar program and don't want to spend the money, your word processor will do a good job with quite a bit less speed and flexibility, and fewer useful functions.)
  27.  
  28.       A second way to create a TEXT file on disk, without using a word processor, is as follows. The ProDOS and DOS WRITE command writes a TEXT file to your disk; that's its raison d'etre. If the TEXT file you wrote to disk contains Applesoft program statements, then you have an EXECable Applesoft program on disk in the form of a TEXTfile.
  29.  
  30.     This one-line program will let you write a TEXTfile on disk containing Applesoft program lines:
  31.  
  32.                0 D$=CHR$(4):POKE 33,33:INPUT"FILE NAME? ";
  33.                  F$:PRINT D$;"OPEN";F$:PRINT D$;"CLOSE";F$:
  34.                  PRINT D$;"DELETE";F$:PRINT D$;"OPEN";F$:
  35.                  PRINT D$;"WRITE";F$:LIST 1,:PRINT D$;
  36.                  "CLOSE";F$:TEXT:END
  37.  
  38.     I won't go into extreme detail on how it works, but for those who are curious, the POKE 33,33 command narrows the screen display to avoid losing the end of longer program lines, which otherwise can occasionally be a problem. There is some debate about whether this POKE is necessary if you are operating in ProDOS; I don't understand the debate, it's no trouble to put the POKE in and it certainly does no harm in ProDOS, so I leave it in in both operating systems. The reason you OPEN, CLOSE and DELETE at the beginning is to erase any TEXTfile already on the disk under the same name as the one you've chosen in response to the "FILE NAME?" input prompt. This is important because if you WRITE a TEXTfile "on top of" an existing TEXTfile, and the new TEXTfile is shorter than the old TEXTfile, then the end of the old TEXTfile will remain on the disk as part of the new TEXTfile and you will be in what is known among programming experts as a "weird situation." Note that after you give the WRITE command, you "LIST 1, ", which LISTS the program in memory from the first line numbered 1 or higher to the end . As the program is LISTed, the WRITE command writes it to disk as an EXECable TEXTfile. THE PROGRAM YOU ARE TRYING TO WRITE TO THE TEXTFILE CANNOT HAVE A LINE NUMBER 0, which must be reserved for the TEXTfile writing program. I put the TEXTfile writing program above onto almost every disk I have as a TEXTfile named "EXECUTARY." Then when I have a program in memory I want to write to disk as a TEXTfile, I just EXEC EXECUTARY into memory, and then type RUN. When you RUN the program, naturally it encounters its new line 0 first; you'll get a "FILE NAME?" prompt, in response to which you type in the name you want the new TEXTfile to have. Then press RETURN and the writing-to-disk process will follow automatically. The TEXT command near the end of line 0 restores the normal width screen, and END prevents the remainder of the program from RUNning.
  39.  
  40.    I put EXECUTARY on disk as a TEXTfile originally with a word processor. It is very much a public domain program, but I want to point out that I got this particular version from the wonderful new publication "Open-Apple" published by Tom Weishaar, 10026 Roe, Overland Park, Kansas, 66207. You will learn more about your Apple in one issue than from 3 years worth of InCider or A+.
  41.  
  42.     Incidentally, you have to put a program into TEXTfile form to upload it to Compuserve, and the EXECUTARY program works fine for that purpose.
  43.  
  44.  
  45.                     OTHER EXECFILE USES
  46.  
  47.    Making a diskful of EXECable subroutines is a very valuable investment of your time if you do any programming, and "typing" the subroutines into memory is a very good use of the EXEC command. But it's far from the only one. You can use an EXEC file to make your Apple do many things. This is accomplished by using those ProDOS/DOS and Applesoft commands that are described as "immediate mode" commands. These are commands that will work when you type them in directly from the keyboard. "Deferred mode" commands only work when used from within an Applesoft program. Almost all immediate mode commands can also be used in deferred mode, but a deferred mode command by definition only works from within a program.
  48.  
  49.    Let me give a very simple demonstration. HOME is an immediate-mode Applesoft command. So is PRINT. So is VTAB which sets the vertical cursor position. So is CATALOG (use CAT if you're in ProDOS). Using your word processor, type the following as shown:
  50.  
  51.                     HOME  <CR>
  52.                     VTAB 10  <CR> PRINT "EXECUTING" <CR>
  53.                     CAT <CR>
  54.  
  55.     Of course, <CR> means press Carriage RETURN. When you finish, save this short EXEC file to disk in TEXTfile form; name it HOME.CAT. Now, exit your word processor and boot up the disk you saved HOME.CAT to. Type EXEC HOME.CAT. As the file EXECS, the screen will clear (HOME), the cursor will move to about midscreen (VTAB 10), the word EXECUTING will appear (PRINT "EXECUTING"), and the disk catalog will then be displayed (CAT; if you're in DOS use CATALOG).
  56.  
  57.     Well, all that does is show you it works. You can give your Apple a series of immediate mode Applesoft and ProDOS/DOS commands without ever touching the keyboard by EXECing a TEXTfile containing those commands. Let me suggest a more interesting use for ProDOS fans.  Your 128k Apple in ProDOS has a RAMdisk available, a portion of memory that is set aside to emulate in many respects a 3d disk drive. You can save programs there, and run them from RAMdisk instantaneously, without noisy and boring disk access. You can do this by a series of typed-in immediate mode commands ( LOAD /SCRATCH/HEX.DEC.CONVERT [sigh!] SAVE /RAM/HEX.DEC.CONVERT [sigh!] LOAD /SCRATCH/STARTUP [yawn] SAVE/RAM/STARTUP [choke!gasp!]...etc,etc, ad nauseam.) Or you can let an EXEC file do it. How?  Here's how to load a series of Applesoft programs into RAMdisk when you boot up. Let's say you have a ProDOS disk named /SCRATCH you use frequently, and that it has a large number of short Applesoft programs on it, and enough directories and files that you have to search a little bit for those short utility programs you frequently use when working off that disk. Let's say those three programs are HEX.DEC.CONVERT, START.ADDR.LOCATE, and WRITE.DATA. Let's say it would be helpful to have those three at your fingertips, in the RAMDISK, while working in main memory.  Write the following EXEC file and save it to the disk named /SCRATCH as a textfile called RAMLOADER:
  58.                     LOAD/SCRATCH/HEX.DEC.CONVERT
  59.                     SAVE/RAM/HEX.DEC.CONVERT
  60.                     LOAD/SCRATCH/START.ADDR.LOCATE
  61.                     SAVE/RAM/START.ADDR.LOCATE
  62.                     LOAD/SCRATCH/WRITE.DATA
  63.                     SAVE/RAM/WRITE.DATA
  64.                     CAT/SCRATCH
  65.                     PRINT"RAM PROGRAMS INSTALLED"
  66.                     PRINT"MAIN MEMORY EMPTY"
  67.                     NEW
  68.  
  69.  
  70.    Now, write the following Applesoft program and save it to the disk named /SCRATCH as a program named STARTUP:
  71.  
  72.                10 HOME:HTAB 10:VTAB 10:
  73.                   PRINT"LOADING RAM"
  74.                20 PRINT CHR$(4);"EXEC /SCRATCH/RAMLOADER"
  75.  
  76.  
  77.     Now, when you boot up /SCRATCH, its startup program will EXECute the TEXTfile named RAMLOADER. That file will, one after the other, load the programs you wanted into main memory, then save them to the RAMdisk, then catalog the disk in the bootup drive, tell you the RAM programs are installed and that main memory is empty, then empty the main memory through the NEW command. And you never had to touch a single key!
  78.  
  79.     You can add a very useful step to this EXEC file. RUN is also an immediate mode Applesoft command. If you want another program on your /SCRATCH disk to RUN on bootup, after you have EXEC'd the RAMDISK full of programs, simply omit the NEW command and add to the end of the above EXECfile the command RUN xxxxx, with the x's of course being the name of the Applesoft BAS program you want to RUN immediately after bootup. And there's more. EXEC is an immediate mode DOS/ProDOS command, so you can EXEC other TEXTfiles by putting such instructions into a textfile. Just look through any Applesoft and ProDOS/DOS command summary you have around, and check out all the immediate mode commands. This should begin to give you some ideas about the variety of functions available through EXEC files.
  80.  
  81.     I hope you find some of this stuff helpful. I myself am just beginning to discover the remarkable power of EXECing TEXTfiles full of immediate mode commands in order to control my Apple.
  82.  
  83.  
  84.                                     Jim Upchurch
  85.